#ifndef IGSLIB_METER_H
#define IGSLIB_METER_H

#include <set>
#include <igslib_imeter.h>

namespace igslib 
{
    class CMeter:virtual public IMeter
    {
        protected:
            float value;
			ISpi* spi;
			IGPIO* gpio;
            std::set<IMeterEvent*> events;
			bool ha;
        public:
            CMeter()
            {
                value = 0;
                spi = nullptr;
				ha=false;
            }
            virtual void SetEventHandler(IMeterEvent* value) { events.insert(value); }
            virtual void Update() { }
            virtual std::string GetName() { return std::string("CMeter"); }
            virtual void SetSPI(ISpi* value) { spi = value; }
            virtual int AddValue(const float& value)
            {
                this->value += value;
                return 0;
            }
            virtual float GetValue() { return value; }
            virtual void Reset() { }
			virtual void SetHighActive(const bool& value){ha=value;}
			virtual int SetGPIO(IGPIO* value)
            {
                gpio=value;
                return 0;
            } 
    };

    class CMeterManager:public IMeterManager
    {
        static IMeterManager* instance;
		char count;
        public:
            static IMeterManager* GetInstance();
            IMeter* NewMHMeter();
			virtual IGPIOMeter* New_ProjGPIOMeter(const std::string& name);
    };
};

#endif
